//
//  JZDJDDetViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/10/28.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "JZDJDDetViewController.h"

@interface JZDJDDetViewController ()

@property (nonatomic,strong)NSDictionary *dic;
@property (weak, nonatomic) IBOutlet UILabel *labOrderName;
@property (weak, nonatomic) IBOutlet UILabel *labOrderPrice;
@property (weak, nonatomic) IBOutlet UILabel *labPrice;
@property (weak, nonatomic) IBOutlet UILabel *labOrder;
@property (weak, nonatomic) IBOutlet UILabel *labDate;
@property (weak, nonatomic) IBOutlet UILabel *labPayMent;
@property (weak, nonatomic) IBOutlet UILabel *labDZ;
@property (weak, nonatomic) IBOutlet UILabel *labPhone;
@property (weak, nonatomic) IBOutlet UILabel *labPlace;
@property (weak, nonatomic) IBOutlet UILabel *labRemark;

@end

@implementation JZDJDDetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self showNav:@"订单详情"];
    [self loadData];
    
}

- (void)loadUI{
    _labOrderName.text = [_dic objectForKey:@"ordername"];
    _labOrderPrice.text = [NSString stringWithFormat:@"%@元/时",[_dic objectForKey:@"ordermoney"]];
    _labPrice.text = [_dic objectForKey:@"ordermoney"];
    _labOrder.text = [_dic objectForKey:@"ordernumber"];
    NSString *addtime = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"addtime"] integerValue]];
    NSString *date = [self getNewDate:addtime];
    _labDate.text = date;
    NSString *payment = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"payment"] integerValue]];
    if ([payment integerValue] == 2) {
        _labPayMent.text = @"微信支付";
    }else if ([payment integerValue] == 3){
        _labPayMent.text = @"支付宝支付";
    }else if ([payment integerValue] == 4){
        _labPayMent.text = @"银联支付";
    }else{
       _labPayMent.text = @"余额支付";
    }
    _labDZ.text = [_dic objectForKey:@"consignee"];
    _labPhone.text = [_dic objectForKey:@"phone"];
    _labPlace.text = [_dic objectForKey:@"address"];
    _labRemark.text = [_dic objectForKey:@"remaek"];
    
}

//家政完成详情
- (void)loadData{
    [SVProgressHUD show];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:_orderId forKey:@"id"];
    [parmas setObject:_merid forKey:@"merchantid"];
    
    NSString *url = [NSString stringWithFormat:@"%@/App/Ordermanage/housekeepingdetails",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"家政完成详情res:%@",responseObject);
//        _array = [[responseObject objectForKey:@"result"] objectForKey:@"delivery"];
        _dic = [responseObject objectForKey:@"result"];
        [self loadUI];
        [SVProgressHUD dismiss];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD dismiss];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
